<?php
namespace Home\Controller;
use Think\Controller;
class RegisterController extends CommonController {
	
    public function ajaxDoRegister(){
		$data['user_tel'] = I('user_tel',null);
		$data['password'] = I('pwd',null);
		$sms_code = I('sms_code',null);
		if(empty($data['user_tel']) || empty($data['password']) || empty($sms_code)){
			$response['msg'] = '参数异常..';
			$response['rsc'] = C('RESPONSE.FAILED');
			$this->ajaxReturn($response);
		}
		// dump(session('sms_code'));
		// dump($sms_code);exit;
		if($sms_code!=session('sms_code')){
			$response['msg'] = '短信验证码错误.';
			$response['rsc'] = C('RESPONSE.FAILED');
			$this->ajaxReturn($response);
		}
		$userSrv = D('UserInfo');
		$dbRes = $userSrv->where("user_tel = '".$data['user_tel']."'")->find();
		if(!empty($dbRes)){
			$response['msg'] = '注册失败，手机号已经存在3';
			$response['rsc'] = C('RESPONSE.FAILED');
			$this->ajaxReturn($response);
		}
		$data['user_id'] = new_doc_id('USER');
		
		$userSrv->data($data)->add();
		$response['msg'] = '注册成功';
		$response['rsc'] = C('RESPONSE.SUCCESS');
		$this->ajaxReturn($response);
	}
}